import siteInfo from 'siteInfo';

//定义接口url
const apiUrl = {
    luckyDraw: {
        getActivityData: 'addons/pond/api.Index/getActivityData',
		playGame: 'addons/pond/api.Award/playGame',
		awardStatus: 'addons/pond/api.Award/awardStatus'
    },
	address:{
		saveUserInfo: 'addons/pond/api.User/saveUserInfo'
	},
	myPrize:{
		getUserAwardList:'addons/pond/api.Award/getUserAwardList',
		getAward:'addons/pond/api.Award/getAward'
	},
	collection:{
		saveAddonsInfo: 'addons/pond/api.Collection/saveAddonsInfo'
	},
	app:{
		getAppInfo:'api/index/config',
		wxLogin:'api/login/wxlogin',
		wxJsConfig:'api/index/wxJsConfig',
		},
	user:{
		share:'addons/pond/api.user/share',
		parent:'addons/pond/api.user/parent',
	}
};





//处理url
const spliceUrl = (ip, apiUrl) => {
    let newUrl = {};
    for (let k in apiUrl) {
        let newOb = {
            [k]: {}
        };
        for (let i in apiUrl[k]) {
            newOb[k][i] = `${ip}${apiUrl[k][i]}`
        }
        newUrl[k] = newOb[k];
    }
    return newUrl;
};

const appendApiUrl = (siteInfo) => {
  let apiRoot = '';
  apiRoot = siteInfo.apiroot
  return spliceUrl(apiRoot, apiUrl);
};

export default appendApiUrl(siteInfo);
